import {url} from './config'
export function uploadFile(params){
    return new Promise((rev,rej)=>{
        wx.uploadFile({
            filePath: params.url,
            name: params.name,
            url: url+'/api/upload/file',
            formData: params.formData,
            header: {
                Authorization : "Bearer " + getApp().globalData.token,
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                console.log(res)
                if(res.statusCode==200){
                    rev(JSON.parse(res.data))
                }else{
                   wx.showToast({
                       icon:'none',
                     title: '上传失败，请重新上传',
                   })
                }
          },
          fail: (res) => {
              rej(res)
          },
          complete: (res) => {},
        })
    })
   
}